package com.qdu.servlet;

import com.qdu.entity.Log;
import com.qdu.service.impl.LogServiceImpl;
import com.qdu.util.GsonUtil;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 查询所有的日志
 *
 * @author Lenovo
 */
@WebServlet("/searchalllogs")
public class SearchAllLogsServlet extends HttpServlet {

    LogServiceImpl logserviceimpl=new LogServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求参数
        //执行业务逻辑
        List<Log> list=logserviceimpl.getAllLog();
        //生成响应内容
        req.setAttribute("logList", list);
        req.getRequestDispatcher("/logForm.jsp").forward(req, resp);//将得到的日志放在请求参数里，然后请求转发，在管理员页面的右边显示
    
//        resp.setContentType("application/x-json;charset=utf-8");//将日志列表转换成Gson类型
//        resp.getWriter().println(GsonUtil.javaToJson(list));
    }

}
